import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/Home.vue'),
      redirect: '/',
      children: [
        {
          path: '/',
          name: 'index',
          component: () => import('../views/Index.vue')
        },
        {
          path: '/tasklist',
          name: 'tasklist',
          component: () => import('../views/TaskList.vue')
        },
        {
          path: '/orderlist',
          name: 'orderlist',
          component: () => import('../views/OrderList.vue')
        },
        {
          path: '/publish',
          name: 'publish',
          component: () => import('../views/Publish.vue')
        },
        {
          path: '/admin',
          name: 'admin',
          component: () => import('../views/Admin.vue')
        }
      ]
    }
  ]
})

router.beforeEach((to, from, next) => {
  document.title = '废品回收系统'
  next()
})

export default router
